<#import "/spring.ftl" as spring />
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="${Request.language}" lang="${Request.language}">
<head>
	<title><@spring.message 'main.title'/></title>

	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8;no-cache"/>

	<link rel="shortcut icon" href="${Request.contextPath}/favicon.ico">
	<link rel="stylesheet" type="text/css" href="${Request.contextPath}/css/reset-min.css"/>
	<link rel="stylesheet" type="text/css" href="${Request.contextPath}/ext/resources/css/ext-all.css"/>
	<link rel="stylesheet" type="text/css" href="${Request.contextPath}/ext/resources/css/xtheme-gray-min.css"/>
	<link rel="stylesheet" type="text/css" href="${Request.contextPath}/css/main-min.css"/>

	<#-- ExtJs libraries -->
	<#if (debug?? || RequestParameters.debug??)>
	<#assign suffix=""/>
	<script type="text/javascript" src="${Request.contextPath}/ext/source/core/Ext.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/ext/source/adapter/ext-base.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/ext/ext-all-debug.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/ux/ext-basex.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/ux/miframe.js"></script>
	<#else>
	<#assign suffix="-min"/>
	<script type="text/javascript" src="${Request.contextPath}/ext/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/ext/ext-all.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/ux/ext-basex-min.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/ux/miframe-min.js"></script>
	</#if>

	<#-- Globals -->
	<script type="text/javascript">
		var CONTEXT_PATH = "${Request.contextPath}";
		var LANGUAGE = "${Request.language}";
		var USER = {
			id: ${user.id?c},
			login: '${user.login}',
			fullname: '${user.fullname}',
			email: '${user.email}',
			language: '${user.language}',
			role: {
				id: ${user.role.id?c},
				name: '${user.role.key}'
			},
			organization:	{
				id: ${user.organization.id?c},
				name: '${user.organization.name}'
			}
		};

		var MODULES = {};
	</script>

	<script type="text/javascript" src="${Request.contextPath}/ux/notification${suffix}.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/ux/lovcombo${suffix}.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/messages-${Request.language}${suffix}.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/common${suffix}.js"></script>

	<#switch (user.role.key)>
	<#case 'role.administrator'>
	<script type="text/javascript" src="${Request.contextPath}/private/admin${suffix}.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/private/admin-org${suffix}.js"></script>
	<#break/>
	<#case 'role.organization.admin'>
	<script type="text/javascript" src="${Request.contextPath}/private/org-admin${suffix}.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/private/org-area${suffix}.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/private/org-qual${suffix}.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/private/org-training${suffix}.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/private/org-unit${suffix}.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/private/org-councils${suffix}.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/private/reports${suffix}.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/private/org-upload${suffix}.js"></script>
	<#break/>
	<#case 'role.organization.designer'>
	<script type="text/javascript" src="${Request.contextPath}/private/org-designer${suffix}.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/private/reports${suffix}.js"></script>
	<#break/>
	<#case 'role.organization.user'>
	<script type="text/javascript" src="${Request.contextPath}/private/org-user${suffix}.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/private/reports${suffix}.js"></script>
	<#break/>
	</#switch>
	<script type="text/javascript" src="${Request.contextPath}/private/user${suffix}.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/private/alfresco${suffix}.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/private/main${suffix}.js"></script>
	<script type="text/javascript" src="${Request.contextPath}/ext/source/locale/ext-lang-${Request.language}${suffix}.js"></script>

</head>
<body>
<script language="javascript">
	Ext.EventManager.on(window, 'load', function() {
		Ext.onReady(Main.app.init, Main.app, true);
	});
</script>
</body>

</html>